package com.yjt.termworks.utils;

import android.content.Context;
import android.content.SharedPreferences;

import java.util.HashMap;
import java.util.Map;

public class SharePreferenceData {
    public static Boolean saveUserData(Context context,String userName, String userPwd){
        SharedPreferences data = context.getSharedPreferences("data", Context.MODE_PRIVATE);
        SharedPreferences.Editor edit = data.edit();
        edit.putString("userName",userName);
        edit.putString("userPwd",userPwd);

        return edit.commit();
    }

    public static Boolean saveUserData2(Context context,String phone){
        SharedPreferences data = context.getSharedPreferences("data2", Context.MODE_PRIVATE);
        SharedPreferences.Editor edit = data.edit();
        edit.putString("phone",phone);
        return edit.commit();
    }
    public static Map<String,String> getUserData2(Context context){
        Map<String, String> stringStringMap = new HashMap<>();
        SharedPreferences data = context.getSharedPreferences("data2", Context.MODE_PRIVATE);
        String phone = data.getString("phone","");
        stringStringMap.put("phone",phone);
        return stringStringMap;
    }

    public static Map<String,String> getUserData(Context context){
        Map<String, String> stringStringMap = new HashMap<>();
        SharedPreferences data = context.getSharedPreferences("data", Context.MODE_PRIVATE);
        String userName = data.getString("userName","");
        String userPwd = data.getString("userPwd","");
        stringStringMap.put("userName",userName);
        stringStringMap.put("userPwd",userPwd);

        return stringStringMap;
    }
}
